<?php
/**
 * Created by PhpStorm.
 * User: mj
 * Date: 17-6-7
 * Time: 下午2:19
 */

namespace App\Winged\Patients\Api;


class User extends Api
{
    public static $actions = [
        'info'                   => 'doctor/info',
        'roles'                  => 'uaa/auth/roles',
        'permissions'            => 'uaa/auth/permissions',
        'user_roles_permissions' => 'uaa/auth/user_roles_permissions',
        'role_permissions'       => 'uaa/auth/role_permissions',
        'users'                  => 'uaa/auth/user_doctors?index=%s&number=%s',
    ];

    /**
     * 获取用户信息
     *
     * @return \Illuminate\Support\Collection|string
     */
    public static function info()
    {
        return self::doGet('info');
    }

    /**
     * 获取系统所有角色信息
     *
     * @return \Illuminate\Support\Collection|string
     */
    public static function roles()
    {
        return self::doGet('roles');
    }

    /**
     * 获取角色所有信息
     *
     * @return \Illuminate\Support\Collection|string
     */
    public static function permissions()
    {
        return self::doGet('permissions');
    }

    /**
     * 更新用户角色和权限
     *
     * @param $info = ['user_id' , 'roles' => [1,2,3] , 'permissions' => [1,2,3]];
     *
     * @return \Illuminate\Support\Collection|string
     */
    public static function updateUserRolesAndPermissions($info)
    {
        return self::doPost('user_roles_permissions', $info);
    }

    /**
     * 更新角色权限
     *
     * @param $info = ['role_id' => 1 , 'permissions' => [1,2,3,4]] ;
     *
     * @return \Illuminate\Support\Collection|string
     */
    public static function updateRoleAndPermissions($info)
    {
        return self::doPost('role_permissions', $info);
    }

    public static function users($currentPage, $currentPageSize)
    {
        return self::doGet('users', $currentPage, $currentPageSize);
    }
}
